package com.example.gmallpublisher.mapper;

import com.example.gmallpublisher.bean.TradeProvinceOrderAmount;
import com.example.gmallpublisher.bean.TradeProvinceOrderCt;
import com.example.gmallpublisher.bean.TradeProvinceUserCt;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @Author Administrator
 * @Time 2022-08-22-15:33
 */
public interface TradeStatsMapper {
    @Select("select province_name,\n" +
            "       count(user_id)  user_count\n" +
            "from dws_trade_province_order_window\n" +
            "where toYYYYMMDD(stt) = #{date}\n" +
            "group by province_id, province_name;")
    List<TradeProvinceUserCt> selectTradeProvinceUserCt(@Param("date") Integer date);

    @Select("select province_name,\n" +
            "       sum(order_count)  order_count\n" +
            "from dws_trade_province_order_window\n" +
            "where toYYYYMMDD(stt) = #{date}\n" +
            "group by province_id, province_name;")
    List<TradeProvinceOrderCt> selectTradeProvinceOrderCt(@Param("date") Integer date);

    @Select("select province_name,\n" +
            "       sum(order_amount) order_amount\n" +
            "from dws_trade_province_order_window\n" +
            "where toYYYYMMDD(stt) = #{date}\n" +
            "and province_name is not null \n" +
            "and province_name !='' \n" +
            "group by province_id, province_name;")
    List<TradeProvinceOrderAmount> selectTradeProvinceOrderAmount(@Param("date") Integer date);
}
